package com.asion.gankapp.model;

import com.asion.gankapp.entrys.BaseMeituEntry;
import com.asion.gankapp.servers.ServiceApi;
import com.asion.gankapp.utils.SetCacheUtils;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by asion on 16-10-6.
 */

public class MeituModel implements BaseModel {

    public void getDatas(int id, int page, AllTypeModel.OnGetEntryDatas onGetEntryDatas){
        new Retrofit.Builder()
                .baseUrl("http://www.tngou.net/tnfs/api/")
                .addConverterFactory(GsonConverterFactory.create())
                .client(SetCacheUtils.setCache())
                .build().create(ServiceApi.class).getMeituCommend(id,page).enqueue(new Callback<BaseMeituEntry>() {
            @Override
            public void onResponse(Call<BaseMeituEntry> call, Response<BaseMeituEntry> response) {
                onGetEntryDatas.onGetEntrySuccess(response.body());
            }

            @Override
            public void onFailure(Call<BaseMeituEntry> call, Throwable t) {
                onGetEntryDatas.onGetEntryError("数据请求失败，请检查网络...");
            }
        });
    }


}
